<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>基础字典管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
    <script type="text/javascript" src="${basePath}/js/ecommerce.js"></script>
</head>
<body>
<div class="content content_frame">
    <h3 class="mainTitle"><img src="${basePath}/images/icon2.png"/>基础字典管理</h3>
    </br>
    <ul class="contentNav dib-wrap">
        <li class="dib" id="btnSearch" defaultkey='13' onclick="reloadGrid()">
            <a><i class='fa fa-search'></i>&nbsp;&nbsp;查&nbsp;询 </a>
        </li>
        <li class="dib ">
            <a onclick="ClearAllInput('SearchTable')">
                <i class='fa fa-refresh'></i>&nbsp;&nbsp;重&nbsp;置 </a>
        </li>
    </ul>
    <br/>
    <table id="SearchTable" class="table1" style="width: 100%">
        <tbody>
        <tr>
            <th class="titleCss" width="130">字典表名</th>
            <td  width="350">
                <input type="text" placeholder="字典表名" datafield="SearchTable.tableName">
            </td>
            <th class="titleCss" width="130">字典表描述</th>
            <td width="350">
                <input type="text" placeholder="字典表描述" datafield="SearchTable.tableDesc">
            </td>
        </tr>
        </tbody>
    </table>
    <div class="cl"></div>
    <br/>

    <table id="corptable" style="height: 1px">
    </table>
    <div id="corptablePage">
    </div>
</div>

</div>
<script type="text/javascript">

    function urlCode(cellvalue, options, rowObject) {
        cellvalue = cellvalue || '';
        cellvalue = $.trim(cellvalue);

        var url = '${basePath}/baseDict/getTDictManagerDetail?tableName=' + rowObject.tableName;
        return "<a class='btn-link' href=\"" + url + "\">" + "<span style='color:#00acec'>" + cellvalue + "</span></a>";
    }

    $(function () {
        $("#corptable").jqGrid({
            datatype: "json",
            url: $basePath + "/baseDict/qryTDictManagerPage",
            colNames: [
                '字典表名',
                '字典表描述',
            ],
            colModel: [
                {name: 'tableName', index: 'tableName', formatter: urlCode, key: true},
                {name: 'tableDesc', index: 'tableDesc'},
            ],
            viewrecords: true,
            autowidth: true,
            height: 'auto',
            shrinkToFit: false,
            autoScroll: true,
            rowNum: 10, //每页显示记录数
            rowList: [10, 20, 100], //可调整每页显示的记录数
            rownumWidth: 35,
            multiselect: false,
            mtype: 'POST',
            width: $('body').width(),
            pager: "#corptablePage", //分页工具栏
            loadComplete: function () {
                var rowNum = $(this).jqGrid('getGridParam', 'records');
                if (rowNum <= 0) {
                    if ($(this).parent().children('.norecords').length == 0)
                        $(this).parent().append("<div class=\"norecords\">暂无数据！</div>");
                    $(this).parent().children('.norecords').show();
                } else {//如果存在记录，则隐藏提示信息。
                    $(this).parent().children('.norecords').hide();
                }
                $("#corptable").setGridWidth($(window).width() * 0.98);
                $(".ui-jqgrid tr.ui-row-ltr td").css('text-align', 'center');
            }
        });
    });

    function reloadGrid() {
        var jsonStr = customFormToData("SearchTable");
        $("#corptable").jqGrid('setGridParam', {
            url: $basePath + "/baseDict/qryTDictManagerPage",
            postData: JSON.parse(jsonStr), //发送数据
            mtype: 'POST',
            page: 1
        }).trigger("reloadGrid"); //重新载入
    }

    $(function () {
        $("#btnSearch").bind("click", function () {
            reloadGrid();
        });
        $("#btnReset").bind("click", function () {
            document.forms[0].reset();
        });
    });

</script>
</body>
</html>
